package com.topisv.tms.repository.stock.instorage;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.stock.instorage.InstorageInfo;

/**
 * 入库信息_dao
 * @author ch
 *
 */
public interface InstorageInfoDao extends PagingAndSortingRepository<InstorageInfo, Long>, JpaSpecificationExecutor<InstorageInfo> {

	@Query("select t from InstorageInfo t where t.uptaskCode=?1 and t.sku=?2")
	InstorageInfo loadByUptaskCode(String uptaskCode,String sku);
	
	@Query("select t from InstorageInfo t where t.uptaskCode=?1 and t.sku=?2 and errorFlag = ?3")
	InstorageInfo loadByUptaskCodeAndFlag(String uptaskCode,String sku,String errorFlag);
	
	@Query("SELECT A FROM InstorageInfo A where A.opeTime >= ?1  and A.opeTime < ?2 order by A.opeTime asc")
	List<InstorageInfo> load30DayAfterRecode(Date startTime,Date endTime);
	
	
	@Query("SELECT min(A.opeTime) FROM InstorageInfo A")
	Date loadMinRecode();
	/**
	 * @zwz 
	 * 边收边上架入库信息查询
	 */
	@Query("select t from InstorageInfo t where t.billCode=?1 and t.uptaskCode=?2 and t.sku=?3 and errorFlag=?4")
	InstorageInfo loadByBillCodeAndLpnAndSkuAndFlag(String billCode,String lpn,String sku,String errorFlag);
	
	

}